package org.examples.simplemulti;

import lombok.extern.slf4j.Slf4j;
import org.apache.hc.client5.http.classic.methods.HttpPost;
import org.apache.hc.client5.http.entity.mime.MultipartEntityBuilder;
import org.apache.hc.client5.http.entity.mime.StringBody;
import org.apache.hc.client5.http.impl.async.CloseableHttpAsyncClient;
import org.apache.hc.client5.http.impl.classic.CloseableHttpClient;
import org.apache.hc.client5.http.impl.classic.HttpClients;
import org.apache.hc.core5.http.ContentType;
import org.apache.hc.core5.http.HttpEntity;
import org.apache.hc.core5.http.io.entity.EntityUtils;

import static org.examples.DebugConstants.vocsInputJson;

@Slf4j
public class blockMulti {
    public static void main(final String[] args) throws Exception {
        final HttpEntity reqEntity = MultipartEntityBuilder.create()
                .addPart("name1", new StringBody("{\"k1\":\"v1\"}", ContentType.APPLICATION_JSON))
                .addPart("name2", new StringBody("{\"k2\":\"v2\"}", ContentType.APPLICATION_JSON))
                .build();
        CloseableHttpClient client = HttpClients.createDefault();
//        HttpPost post = new HttpPost("http://47.108.196.76:8080/post");
//        HttpPost post = new HttpPost("https://leiyang.icu/post");
        HttpPost post = new HttpPost("https://httpbin-qa.na.onecloud.hosting.cerence.net/post");
        post.setEntity(reqEntity);
        client.execute(post, resp -> {
            log.info(EntityUtils.toString(resp.getEntity()));
            return resp;
        });
    }
}
